var checkAll = document.getElementById('checkAll');
var items = document.getElementsByClassName('item');

checkAll.onclick = function() {
  var checked = this.checked;
  for (var i = 0; i < items.length; i++) {
    items[i].checked = checked;
  }
};

for (var i = 0; i < items.length; i++) {
  items[i].onclick = function() {
    var allChecked = true;
    for (var j = 0; j < items.length; j++) {
      if (!items[j].checked) {
        allChecked = false;
        break;
      }
    }
    checkAll.checked = allChecked;
  };
}